<template>
  <div style="margin-top: 30px;margin-left:200px; width: 700px;">
    <el-form
      :model="ruleForm"
      ref="ruleForm"
      label-width="100px"
      class="demo-ruleForm"
    >
      <el-form-item label="学校" prop="school">
                <el-input type="text"
                          v-model="ruleForm.school"
                ></el-input>
            </el-form-item>
            <el-form-item label="最高学历" prop="maxDegree">
                <el-input type="text"
                          v-model="ruleForm.maxDegree"
                ></el-input>
            </el-form-item>
            <el-form-item label="专业" prop="major">
                <el-input type="text"
                          v-model="ruleForm.major"
                ></el-input>
            </el-form-item>
            <el-form-item label="入学时间" prop="begDate">
                <el-date-picker
                    v-model="ruleForm.begDate"
                    type="date"
                    placeholder="出生日期"
                    >
                </el-date-picker>
            </el-form-item>
            <el-form-item label="毕业时间" prop="endDate">
                <el-date-picker
                    v-model="ruleForm.endDate"
                    type="date"
                    placeholder="出生日期"
                    >
                </el-date-picker>
            </el-form-item>
            <el-form-item label="曾获奖项" prop="award">
                <el-input type="text"
                          v-model="ruleForm.award"
                ></el-input>
            </el-form-item>
            <el-form-item label="学校经历" prop="exSchool">
                <el-input type="text"
                          v-model="ruleForm.exSchool"
                ></el-input>
            </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="submitForm('ruleForm')">立即修改</el-button>
        <el-button @click="resetForm('ruleForm')">重置</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
export default {
  category: null,
  data() {
    return {
      ruleForm: {
      eid:'',
      rid:'',
      school:'',
      maxDegree:'',
      major:'',
      begDate:'',
      endDate:'',
      award:'',
      exSchool:'',
      }
    };
  },
  methods: {
    submitForm(formName) {
      const _this = this;
      this.$refs[formName].validate(valid => {
        //提交后
         if (valid) {
                        axios.put('http://localhost:8182/education/update',_this.ruleForm).then(function (resp) {
                            if(resp.data.code == 0){
                                _this.$alert('修改成功', '', {
                                    confirmButtonText: '确定',
                                    callback: action => {
                                        _this.$router.push('/resume')
                                    }
                                });
                            }
                        })
                    }
                });
                },
            
    resetForm(formName) {
      this.$refs[formName].resetFields();
    }
  },
  //拿后台数据
    created(){
      const _this = this;
      axios.get('http://localhost:8182/education/findById/'+_this.$route.query.id).then(function(resp){
        _this.ruleForm=resp.data.data
      })
      /* console.log(_this.$route.query.id) */
    }
};
</script>
